﻿#-*-coding:utf-8 -*-
import decimal
import json

def CalculationRules(jsonArray):
    #jsonArray = '[{"AnalytesCode":"A0","Final":"0.12"},{"AnalytesCode":"A1","Final":null}]'
    resultList = json.loads(jsonArray)

    if len(resultList) == 0:
        return ''

    try:
        for item in resultList:
            if item["AnalytesCode"] == "A0":
                a0 = item["Final"]

            if item["AnalytesCode"] == "A1":
                returnCode = "A1"

        if a0.replace('.','').isdecimal():
	        value = decimal.Decimal(a0)
	        return ','.join([returnCode,str(value),'合格'])

    except:
        return '测试规则代码出现异常，请联系管理员！'
